﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestMatrix.Model;

namespace TestMatrix.DataModel.Factory
{
    public class DataSources
    {
        private IDataSourceItem _dataSourceItem;

        public DataSources(DataSourceType dataSourceType)
        {
            IDataSourceFactory factory;
            switch (dataSourceType)
            {
                case DataSourceType.SQLite:
                    factory = new SQLiteDataSource();
                    _dataSourceItem = factory.CreateDataSource();
                    break;

                case DataSourceType.TOLinq:
                    factory = new ToLinqDataSource();
                    _dataSourceItem = factory.CreateDataSource();
                    break;
            }
        }

        public object GetDataSource()
        {
            return _dataSourceItem.GetDataSource();
        }

        #region tblETLHistory
        public List<tblETLHistory> QueryTblETLHistory(string sql)
        {
            return _dataSourceItem.QueryTblETLHistory(sql);
        }
        #endregion

        #region tblBugList
        public List<tblBugList> QueryTblBugList(string sql)
        {
            return _dataSourceItem.QueryTblBugList(sql);
        }

        public List<tblBugList> QueryTblBugList(string sql, params string[] args)
        {
            return _dataSourceItem.QueryTblBugList(sql, args);
        }

        public void InsertBugs(tblBugList bugs)
        {
            _dataSourceItem.InsertBugs(bugs);
        }
        public void InsertAllBugs(List<tblBugList> bugs)
        {
            _dataSourceItem.InsertAllBugs(bugs);
        }

        public void DeleteAllBugs()
        {
            _dataSourceItem.DeleteAllBugs();
        }
        #endregion

        #region tblNumOfCreatedTC
        public List<tblNumOfCreatedTC> QueryTblNumOfCreatedTC(string sql)
        {
            return _dataSourceItem.QueryTblNumOfCreatedTC(sql);
        }

        public List<tblNumOfCreatedTC> QueryTblNumOfCreatedTC(string sql, params string[] args)
        {
            return _dataSourceItem.QueryTblNumOfCreatedTC(sql, args);
        }

        public void InsertTblNumOfCreatedTC(tblNumOfCreatedTC tc)
        {
            _dataSourceItem.InsertTblNumOfCreatedTC(tc);
        }

        public void DeleteAllTblNumOfCreatedTC()
        {
            _dataSourceItem.DeleteAllTblNumOfCreatedTC();
        }
        #endregion

        #region TblTestAutomation
        public List<tblTestAutomation> QueryTblTestAutomation(string sql)
        {
            return _dataSourceItem.QueryTblTestAutomation(sql);
        }

        public List<tblTestAutomation> QueryTblTestAutomation(string sql, params string[] args)
        {
            return _dataSourceItem.QueryTblTestAutomation(sql, args);
        }

        public void InsertTblTestAutomation(tblTestAutomation tc)
        {
            _dataSourceItem.InsertTblTestAutomation(tc);
        }

        public void DeleteAllTblTestAutomation()
        {
            _dataSourceItem.DeleteAllTblTestAutomation();
        }
        #endregion

        #region tblNumOfExecutedTC
        public List<tblNumOfExecutedTC> QuerytblNumOfExecutedTC(string sql)
        {
            return _dataSourceItem.QuerytblNumOfExecutedTC(sql);
        }

        public List<tblNumOfExecutedTC> QuerytblNumOfExecutedTC(string sql, params string[] args)
        {
            return _dataSourceItem.QuerytblNumOfExecutedTC(sql, args);
        }

        public void InserttblNumOfExecutedTC(tblNumOfExecutedTC tc)
        {
            _dataSourceItem.InserttblNumOfExecutedTC(tc);
        }

        public void DeleteAlltblNumOfExecutedTC()
        {
            _dataSourceItem.DeleteAlltblNumOfExecutedTC();
        }
        #endregion


        #region tblReleaseInfo
        public List<tblReleaseInfo> QuerytblReleaseInfo(string sql)
        {
            return _dataSourceItem.QuerytblReleaseInfo(sql);
        }

        public List<tblReleaseInfo> QuerytblReleaseInfo(string sql, params string[] args)
        {
            return _dataSourceItem.QuerytblReleaseInfo(sql, args);
        }

        public void InserttblReleaseInfo(tblReleaseInfo tc)
        {
            _dataSourceItem.InserttblReleaseInfo(tc);
        }

        public void InsertAlltblReleaseInfo(List<tblReleaseInfo> tc)
        {
            _dataSourceItem.InsertAlltblReleaseInfo(tc);
        }

        public void UpdatetblReleaseInfo(tblReleaseInfo tc)
        {
            _dataSourceItem.UpdatetblReleaseInfo(tc);
        }

        public void DeleteAlltblReleaseInfo()
        {
            _dataSourceItem.DeleteAlltblReleaseInfo();
        }
        #endregion

        #region tblReleaseDetailInfo
        public List<tblReleaseDetailInfo> QuerytblReleaseDetailInfo(string sql)
        {
            return _dataSourceItem.QuerytblReleaseDetailInfo(sql);
        }

        public List<tblReleaseDetailInfo> QuerytblReleaseDetailInfo(string sql, params string[] args)
        {
            return _dataSourceItem.QuerytblReleaseDetailInfo(sql, args);
        }

        public void InserttblReleaseDetailInfo(tblReleaseDetailInfo tc)
        {
            _dataSourceItem.InserttblReleaseDetailInfo(tc);
        }

        public void InsertAlltblReleaseDetailInfo(List<tblReleaseDetailInfo> tc)
        {
            _dataSourceItem.InsertAlltblReleaseDetailInfo(tc);
        }

        public void UpdatetblReleaseDetailInfo(tblReleaseDetailInfo tc)
        {
            _dataSourceItem.UpdatetblReleaseDetailInfo(tc);
        }

        public void DeleteAlltblReleaseDetailInfo()
        {
            _dataSourceItem.DeleteAlltblReleaseDetailInfo();
        }
        #endregion

        #region tblTestCaseInCI
        public List<tblTestCaseInCI> QuerytblTestCaseInCI(string sql)
        {
            return _dataSourceItem.QuerytblTestCaseInCI(sql);
        }

        public List<tblTestCaseInCI> QuerytblTestCaseInCI(string sql, params string[] args)
        {
            return _dataSourceItem.QuerytblTestCaseInCI(sql, args);
        }

        public void InserttblTestCaseInCI(tblTestCaseInCI tc)
        {
            _dataSourceItem.InserttblTestCaseInCI(tc);
        }

        public void DeleteAlltblTestCaseInCI()
        {
            _dataSourceItem.DeleteAlltblTestCaseInCI();
        }
        #endregion

        #region tblGolbalTestCasePassRate
        public List<tblGlobalTestCasePassRate> QuerytblGolbalTestCasePassRate(string sql)
        {
            return _dataSourceItem.QuerytblGolbalTestCasePassRate(sql);
        }

        public List<tblGlobalTestCasePassRate> QuerytblGolbalTestCasePassRate(string sql, params string[] args)
        {
            return _dataSourceItem.QuerytblGolbalTestCasePassRate(sql, args);
        }

        public void InserttblGolbalTestCasePassRate(tblGlobalTestCasePassRate tc)
        {
            _dataSourceItem.InserttblGolbalTestCasePassRate(tc);
        }

        public void DeleteAlltblGolbalTestCasePassRate()
        {
            _dataSourceItem.DeleteAlltblGolbalTestCasePassRate();
        }
        #endregion

        #region tblGlobalTestCaseAutomation
        public List<tblGlobalTestCaseAutomation> QuerytblGlobalTestCaseAutomation(string sql)
        {
            return _dataSourceItem.QuerytblGlobalTestCaseAutomation(sql);
        }

        public List<tblGlobalTestCaseAutomation> QuerytblGlobalTestCaseAutomation(string sql, params string[] args)
        {
            return _dataSourceItem.QuerytblGlobalTestCaseAutomation(sql, args);
        }

        public void InserttblGlobalTestCaseAutomation(tblGlobalTestCaseAutomation tc)
        {
            _dataSourceItem.InserttblGlobalTestCaseAutomation(tc);
        }

        public void DeleteAlltblGlobalTestCaseAutomation()
        {
            _dataSourceItem.DeleteAlltblGlobalTestCaseAutomation();
        }
        #endregion

        #region tblGlobalDRE
        public List<tblGlobalDRE> QuerytblGlobalDRE(string sql)
        {
            return _dataSourceItem.QuerytblGlobalDRE(sql);
        }

        public List<tblGlobalDRE> QuerytblGlobalDRE(string sql, params string[] args)
        {
            return _dataSourceItem.QuerytblGlobalDRE(sql, args);
        }

        public void InserttblGlobalDRE(tblGlobalDRE tc)
        {
            _dataSourceItem.InserttblGlobalDRE(tc);
        }

        public void DeleteAlltblGlobalDRE()
        {
            _dataSourceItem.DeleteAlltblGlobalDRE();
        }
        #endregion
    }

    // <summary>
    /// DataSource Type
    /// </summary>
    public enum DataSourceType
    {
        SQLite,
        TOLinq
    }
}
